
download2()
function download2() {
    ajax({
        url: "./data/goodsList2.json",
        type: "GET",
        callback: function (res) {
            var res = JSON.parse(res)
            // console.log(res)
            render(res)
            shop(res)
        }
    })
}
function render(data) {
    for (var i = 0; i < data.length; i++) {
        var obj = data[i]
        var node = $(`
<div data-v-45ef62b1 class = 'span10 product-cell shadow' data-index="${obj.product_id}">
<div data-v-45ef62b1 class = 'figure'>
    <a data-v-45ef62b1  class = 'exposure'>
        <img data-v-45ef62b1 style = 'background-color: rgb(189, 193, 217);' src="${obj.image}" alt=""/>
    </a>
</div>
<h3 data-v-45ef62b1 class = 'title'>
    <a data-v-45ef62b1 >${obj.name}</a>
</h3>
<p data-v-45ef62b1 class = 'desc'>${obj.desc} </p>
<p data-v-45ef62b1 class = 'price'>
    <strong data-v-45ef62b1>${obj.price}</strong>元
    <span data-v-45ef62b1>起</span>
    <del data-v-45ef62b1>${obj.del}元</del>
</p>
</div> 
`)
        node.appendTo(".row")
    }
}

function shop(data) {
    // console.log(data)
    setTimeout(function () {
        var div_list = document.querySelectorAll(".product-cell")
        // console.log(div)
        for (var j = 0; j < div_list.length; j++) {
            var div = div_list[j]
            div.onclick = function () {  
                 var index = this.getAttribute("data-index")             
                location.href="./gooddec.html?"+"product_id="+index
            }
        }
    }, 200)

}




